﻿using System;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Instances;

namespace Magalie.Data.NHibernateMaps.Conventions
{
    /// <summary>
    /// Convention de nommage des clés primaires
    /// </summary>
    public class PrimaryKeyConvention : IIdConvention
    {
        /// <summary>
        /// Apply changes to the target
        /// </summary>
        public void Apply(IIdentityInstance instance)
        {
            instance.Column(instance.EntityType.Name + "ID");
            // We could include other details, such as those shown below, but the Northwind DB 
            // mixes up assigned Ids, generated Ids, string Ids and int Ids; thus, making it 
            // difficult to put in a single convention for this
            //.WithUnsavedValue(0)
            //.GeneratedBy.Identity();
        }
    }
}